<template>
  <div>
    <h2>我是父组件第二个孩子，接收兄弟的mitt传参:{{ eventBusName }}</h2>
    <br>
    <h2>利用provide传递值msgPro:{{ msgPros }}</h2>
    <br>
    <h2>----------我是pinia存储的值-----</h2>
    <button @click="handlerCha">修改值</button><button @click="reset">重置信息</button>
    <br>
    <h2>
      {{ countStore.counter }}
      {{ countStore.userInfo }}
    </h2>
    <h2>
      <el-button type="primary" size="small" @click="goRouter">路由跳转</el-button>
    </h2>
  </div>
</template>

<script setup>
import {ref, reactive, onMounted,nextTick,onUnmounted,inject} from 'vue'
import { useRouter } from "vue-router";
const router = useRouter();
import EventBus from '@/untils/eventBus.js';
import useUserStore  from "@/store/modules/user";
// import { useMainStore } from "@/store/index";
const countStore = useUserStore();
// const useMainStores = useMainStore();
console.log("@@@@==",countStore);
console.log("@@@@==",countStore.counter);
// console.log("@@@@111111111111==",useMainStores.num);
const eventBusName = ref("")
const msgPros = inject('msgPros')
// const userInfo = ref(null)
const handlerCha = ()=>{
    countStore.increment(3);
    let obj = {
        name:"shw",
        account:"H7865412",
        address:"就撒都发了就是",
        lantId:"551",
    }
    countStore.updateUser(obj)
}
const reset = ()=>{
    countStore.$reset()
}
const goRouter = ()=>{
  router.push({
    path:"/routerOne",
    query:{
      id:1,
      name:"shw"
    }
  })
}
//组件卸载时候，解绑send-toy事件
onUnmounted(()=>{
    EventBus.off("message-event")
})
onMounted(() => {
    EventBus.on('message-event', (message) => {
    console.log(message);
    eventBusName.value = message;
  });
});
</script>
<style scoped>
</style>